remotemanager.storage.database module

class remotemanager.storage.database.Database(file)[source]

Database file handler for use in the Dataset.

Warning

Interacting with this object directly could cause unstable behaviour. It is best to allow Dataset to handle the Database

Parameters:

file (str) – filename to write to

read()[source]

Read the database file

write()[source]

Write the database to file

update(payload)[source]

Update the database with payload (dict)

Parameters:

payload (dict) – Dictionary to recursively update with. Usually called with the output of object.pack()

property path

Path to current database file

property tree: list

Returns a list of path-like strings for the stored database dict

Returns (list):

List of path-like strings

climb(data: dict, branch: list = None) list[source]

“climb” a dictionary tree, returning a list of path-like strings for each element

Note

This method is intended for use within the tree property, and could cause unintended behaviour if called directly, though will allow you to produce a tree like list for any dictionary. Use with caution.

Parameters:
  • data (dict) – dictionary to treat

  • branch (list) – current branch, used for recursion

Returns (list):

list of path-like strings

find(key: str, greedy: bool = False) dict[source]

Find the first instance of key within the database tree

Parameters:
  • key – key (uuid) to look for

  • greedy – returns the first value found if True. Faster, but does not respect the tree “layers”

Returns:

database tree below key

backup(file=None) str[source]

Back up the database file to file, defaults to {self.path}.bk

Parameters:

file – backup file target location

Returns:

backup file path

remotemanager.storage.database.chain_get(d: dict, keys: list)[source]

Get item from a nested dict using a list of keys

Parameters:
  • d (dict) – nested dict to query

  • keys (list) – list of keys to use

Returns:

item from nested dict d at [list, of, keys]

remotemanager.storage.database.check_version_barriers(old: Version, new: Version, barriers: dict) bool[source]

Takes two versions, and a dict of {old: new} that contain breaking changes

Returns True if the two versions are compatible, False otherwise

Parameters:
  • old – old version

  • new – new version

  • barriers

    dictionary of incompatible {old: new} parings.

    Uses the syntax of Version.match